<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<h:body>
	<ui:composition template="/pages/protected/templates/master.xhtml">
		<ui:define name="divMain">
			<h:form id="formPrincipalConstrutora">
						
				<p:dataTable id="construtoraTable" value="#{construtoraMB.todasConstrutoras}" var="construtora" emptyMessage="#{bundle.noRecords}" 
					 widgetVar="tabelaDeConstrutoras">
					
			        <p:column filterBy="#{construtora.razaoSocial}"
			                headerText="Razao Social">  
			            <h:outputText value="#{construtora.razaoSocial}" />  
			        </p:column>
			        <p:column>
						<p:commandButton value="Detalhar" icon="ui-icon-pencil" onclick="dialogoDetalhesConstrutoraWidget.show();" update=":formDetalhesConstrutora" >
							<f:setPropertyActionListener target="#{construtoraMB.construtora}" value="#{construtora}" />
						</p:commandButton>
						<p:spacer width="10px" />
						
						<p:commandButton value="Atualizar" icon="ui-icon-pencil" onclick="dialogoAtualizarConstrutoraWidget.show();" update=":formAtualizarConstrutora" >
							<f:setPropertyActionListener target="#{construtoraMB.construtora}" value="#{construtora}" />
						</p:commandButton>
						<p:spacer width="10px" />
						
						<p:menuButton value="Histórico" >
							<p:menuitem value="Salvar" onclick="dialogoHistoricoConstrutoraWidget.show();" update=":formHistoricoConstrutora" icon="ui-icon-disk" >
								<f:setPropertyActionListener target="#{construtoraMB.construtora}" value="#{construtora}" />
							</p:menuitem>
							<p:menuitem value="Visualizar" action="#{construtoraMB.listarHistoricoDaConstrutora(construtora)}" onclick="dialogoVisualizarHistoricoConstrutoraWidget.show();" update=":formVisualizarHistoricoConstrutora" icon="ui-icon-arrowrefresh-1-w"/>
							<p:menuitem value="Gerar PDF"  actionListener="#{gerarPDFMB.gerarPDF()}" />					        
						</p:menuButton>
						<p:spacer width="10px" />						
											
						<p:commandButton value="Apagar" icon="ui-icon-trash" update=":formApagarConstrutora" onclick="dialogoApagarConstrutoraWidget.show();" >
							<f:setPropertyActionListener target="#{construtoraMB.construtora}" value="#{construtora}" />
						</p:commandButton>
								
					</p:column>
        
				</p:dataTable>
				<p:commandButton value="Cadastrar" icon="ui-icon-plus" update=":formCadastrarConstrutora"
					actionListener="#{construtoraMB.limparConstrutora()}" onclick="dialogoCadastrarCostrutoraWidget.show();" />
			</h:form>
			
			<ui:include src="/pages/protected/admin/dialogosConstrutora/dialogoCadastrarConstrutora.xhtml" />
			<ui:include src="/pages/protected/admin/dialogosConstrutora/dialogoDetalhesConstrutora.xhtml" />
			<ui:include src="/pages/protected/admin/dialogosConstrutora/dialogoAtualizarConstrutora.xhtml" />
			<ui:include src="/pages/protected/admin/dialogosConstrutora/dialogoHistoricoConstrutora.xhtml" />
			<ui:include src="/pages/protected/admin/dialogosConstrutora/dialogoVisualizarHistoricoConstrutora.xhtml" />
			<ui:include src="/pages/protected/admin/dialogosConstrutora/dialogoApagarConstrutora.xhtml" />
		
		</ui:define>
	</ui:composition>
</h:body>
</html>